package com.sqstudio.exercise.chapter4{
	
	import flash.events.Event;
	
	import org.osmf.events.DisplayObjectEvent;
	import org.papervision3d.events.InteractiveScene3DEvent;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;

	[SWF(width="800",height="600")]
	public class Object3DActivity extends BasicView
	{
		public function Object3DActivity(viewportWidth:Number=800, viewportHeight:Number=600, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target")
		{
			super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
			stage.frameRate = 40;
			init();
			this.startRendering();
		}
		
		private function init():void{
			var colorMaterial:ColorMaterial = new ColorMaterial();
			colorMaterial.doubleSided = true;
			colorMaterial.interactive = true;
			viewport.interactive = true;
			
			var plane:Plane = new Plane(colorMaterial,500,300,5,4);
			scene.addChild(plane);
			plane.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK,do3dCKHandler);
		}
		
		private function do3dCKHandler(e:InteractiveScene3DEvent):void
		{
			// TODO Auto-generated method stub
			e.displayObject3D.localRotationY+=60;
		}
		
		override protected function onRenderTick(event:Event=null):void
		{
			super.onRenderTick(event);
		}
	}
}